#define  _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int t = 0;
	if (a < b)
	{
		t = a;
		a = b;
		b = t;
	}
	t = a % b;
	while (t != 0)
	{
		a = b;
		b = t;
		t = a % b;
	}

	printf("%d ", b);
	return 0;
}